<!--  -->
<template>
  <div class="detail_relate">
    <div
      class="goods"
      v-for="item in relateData"
      :key="item.id"
      @click="toDetail(item.id)"
    >
      <GoodsBox :data="item"></GoodsBox>
    </div>
  </div>
</template>

<script>
import { defineComponent } from "vue";
import { useRouter } from "vue-router";
import GoodsBox from "@/components/GoodsBox.vue";
export default defineComponent({
  name: "DetailRelate",
  components: {
    GoodsBox,
  },
  props: {
    relateData: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  setup() {
    const router = useRouter();
    const toDetail = (id) => {
      router.replace({
        path: "/detail",
        query: {
          id,
        },
      });
    };
    return {
      toDetail,
    };
  },
});
</script>

<style lang="scss" scoped>
.detail_relate {
  width: 100%;
  background-color: #fff;
  display: flex;
  justify-content: space-between;
  flex-flow: wrap;
  padding: 20px;
}
.goods {
  width: 49%;
}
</style>
